// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package base

import (
	"context"
	"time"
)

type (
	// Span
	// is an interface for call chain span.
	Span interface {
		// Child
		// creates a child span on the span.
		Child(name string) Span

		// Context
		// returns the context of the span.
		Context() context.Context

		// Duration
		// returns the duration of the span.
		Duration() time.Duration

		// End
		// ends the span.
		End()

		// EndTime
		// returns the end time of the span.
		EndTime() time.Time

		// Logs
		// returns the logs of the span.
		Logs() []*Item

		// Name
		// returns the name of the span.
		Name() string

		// Release
		// put the span to the pool.
		Release()

		// StartTime
		// returns the start time of the span.
		StartTime() time.Time

		// Tracing
		// returns the tracing component of the span.
		Tracing() *Tracing

		SpanWithAttr
		SpanWithLogger
	}

	SpanWithAttr interface {
		// GetAttr
		// returns the attr of the span.
		GetAttr() Attr

		// SetAttr
		// sets the attr of the span.
		SetAttr(key string, val any)
	}

	SpanWithLogger interface {
		// Debug
		// send debug level log.
		Debug(format string, args ...any)

		// Info
		// send info level log.
		Info(format string, args ...any)

		// Warn
		// send warn level log.
		Warn(format string, args ...any)

		// Error
		// send error level log.
		Error(format string, args ...any)

		// Fatal
		// send fatal level log.
		Fatal(format string, args ...any)
	}
)
